package ui.magic.magicui;

import android.graphics.Color;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;

import ui.magic.magiclibs.container.Absolute.AbsoluteMagicUi;
import ui.magic.magiclibs.container.Frame.FrameMagicUi;
import ui.magic.magiclibs.container.Linear.LinearMagicUi;
import ui.magic.magiclibs.container.View.AdvertisePlayer;

public class MulActivity extends AppCompatActivity implements View.OnClickListener{

    private LinearMagicUi linearMagicUi;
    private FrameMagicUi frameMagicUi;
    private AbsoluteMagicUi absoluteMagicUi;
    private AbsoluteMagicUi mainUi;
    private Button btn1;
    private Button btn2;
    private Button btn3;
    private Button btn4;
    private Button btn5;
    private Button btn6;
    private AdvertisePlayer advertisePlayer;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_mul);
        mainUi=(AbsoluteMagicUi) findViewById(R.id.main_ui);
        init();
    }

    public void init(){
        linearMagicUi=new LinearMagicUi(mainUi.getContext());
        frameMagicUi=new FrameMagicUi(mainUi.getContext());
        absoluteMagicUi=new AbsoluteMagicUi(mainUi.getContext());
        btn1=new Button(linearMagicUi.getContext());
        btn2=new Button(linearMagicUi.getContext());
        btn3=new Button(frameMagicUi.getContext());
        btn4=new Button(frameMagicUi.getContext());
        btn5=new Button(absoluteMagicUi.getContext());
        btn6=new Button(absoluteMagicUi.getContext());
        advertisePlayer=new AdvertisePlayer(mainUi.getContext());
        advertisePlayer.setAdvertiseNums(4);
        advertisePlayer.setUnderItemColor(Color.CYAN);
        advertisePlayer.addAdvertiseRes(R.drawable.school1);
        advertisePlayer.addAdvertiseRes(R.drawable.zhibo);
        linearMagicUi.addChild(btn1,40,40);
        linearMagicUi.addChild(btn2,40,40);
        frameMagicUi.addChild(btn3,80,80);
        btn4.setBackgroundColor(Color.DKGRAY);
        frameMagicUi.addChild(btn4,40,40);
        btn3.setOnClickListener(this);
        absoluteMagicUi.addChild(btn5,10,10,30,30);
        absoluteMagicUi.addChild(btn6,40,10,30,30);
        mainUi.addChild(linearMagicUi,5,5,80,20);
        mainUi.addChild(frameMagicUi,5,30,80,40);
        mainUi.addChild(absoluteMagicUi,5,70,80,20);
        mainUi.addChild(advertisePlayer,0,0,100,20);

    }

    @Override
    public void onClick(View v) {
        mainUi.changeChildSize(frameMagicUi,60,30);
    }
}
